package com.zwxu.upload;

import java.util.HashMap;


public class ResumableInfoStorage {

    //Single instance
    private ResumableInfoStorage() {
    }
    private static ResumableInfoStorage sInstance;

    public static synchronized ResumableInfoStorage getInstance() {
        if (sInstance == null) {
            sInstance = new ResumableInfoStorage();
        }
        return sInstance;
    }

    //resumableIdentifier --  ResumableInfo
    private HashMap<String, ResumableInfo> mMap = new HashMap<String, ResumableInfo>();


    public ResumableInfo get(ResumableInfo resumableInfo) {

        ResumableInfo info = mMap.get(resumableInfo.getResumableIdentifier());

        if (info == null) {
            //info = new ResumableInfo();
            info = resumableInfo;

            mMap.put(resumableInfo.getResumableIdentifier(), info);
        }
        return info;
    }


    public void remove(ResumableInfo info) {
       mMap.remove(info.getResumableIdentifier());
    }
}
